﻿using System;
using System.Collections.Generic;
using Service.Infrastructure.Implement;
using Service.Infrastructure.Interface;
using Service.Infrastructure.Result;
using SystmicFunction.Public.CharacterService;

namespace Service.Infrastructure
{
    /// <summary>
    ///     全局变量
    /// </summary>
    public static class MemoryCache
    {
        /// <summary>
        ///     全局缓存管理类
        /// </summary>
        public static Dictionary<String, String> CacheSetting { get; set; }


        /// <summary>
        /// 平台初始
        ///     全局变量随系统启动或重启都会初始一次
        /// </summary>
        public static void Init()
        {
            IPlatformInitialization config = new PlatformConfigService();
            config.Init();
            IPlatformInitialization manager = new ManagerService();
            manager.Init();
        }

        /// <summary>
        ///  心跳机制：每次请求都会延迟session的活性
        /// </summary>
        /// <param name="account">要执行的实现类</param>
        /// <param name="sessionKey">缓存唯一标识</param>
        /// <param name="props">缓存中的数据</param>
        public static ServiceResult GetSessionData(IAccount account, String sessionKey, params Object[] props)
        {
            //TODO:缓存数据
            return account.KeepSession(sessionKey, props);
        }

        /// <summary>
        ///     生成SessionKey
        /// </summary>
        public static String GenerateKey()
        {
            return String.Format("{0}-{1}", Guid.NewGuid(), DtHelper.GetTimeStamp());
        }




    }
}
